import React, { Component } from 'react';
import './assets/css/App.css';
import './assets/css/index.css';
// 安装并引入路由
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';

// 引入模块化路由配置

import routers from './model/router';
class App extends Component {
  render() {
    return (
      <Router>
        <div>
          <header className="header">
            <Link to="/">最新</Link>
            <Link to="/category">产品分类</Link>
            <Link to="/user">个人中心</Link>
            <Link to="/login">登录</Link>
          </header>
          {
            routers.map((route,key)=>{
              if (route.exact) {
                return <Route key={key} exact path={route.path} render={props => (
                  <route.component {...props} routes={route.routes} />
                )}/>
              } else {
                return <Route key={key} path={route.path}  render={props => (
                  <route.component {...props} routes={route.routes} />
                )}/>
              }
            })
          }
        </div>
      </Router>
    );
  }
}

export default App;
